package com.jzt.qf.service.GetService.Impl;

import com.alibaba.fastjson.JSON;
import com.jzt.qf.beans.jztBean.JztCloseBuyBillBean;
import com.jzt.qf.beans.jztBean.JztRKJson;
import com.jzt.qf.service.GetService.GetInStockService;
import com.jzt.qf.beans.HttpResult;
import com.jzt.qf.beans.UploadBase;
import com.jzt.qf.beans.jztBean.GET_InStock;
import com.jzt.qf.https.JztApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 　* @description:获取入库service实现类
 * 　* @author zxy
 * 　* @date 2020-07-23 14:33
 */
@Slf4j
@Service
public class GetInStockServiceImpl implements GetInStockService {
    @Resource
    private JztApi jztApi;
    /**
     * 采购入库回传
     *
     * @param uploadBase
     * @return
     */
    @Override
    public HttpResult getBuy(UploadBase uploadBase) {
        log.info("获取九州通入库单查询条件(采购入库回传)" + JSON.toJSONString(uploadBase));
        HttpResult<GET_InStock> httpResult = jztApi.HttpRequest(uploadBase);
        log.info("获取九州通入库单返回的数据(采购入库回传)" + JSON.toJSONString(httpResult));
        return httpResult;
    }

    @Override
    public HttpResult closeBuyBillByBill_Dtl_Id_jzyc(String bill_Dtl_Id_jzyc) {
        List<JztCloseBuyBillBean> list = new ArrayList<>();
        JztCloseBuyBillBean jztCloseBuyBillBean = new JztCloseBuyBillBean();
        jztCloseBuyBillBean.setBill_Dtl_Id_jzyc(bill_Dtl_Id_jzyc);
        list.add(jztCloseBuyBillBean);
        UploadBase jztRKJsonUploadBase = new UploadBase("rksc", "updated", list);
        HttpResult httpResult = jztApi.HttpRequest(jztRKJsonUploadBase);
        log.error(bill_Dtl_Id_jzyc + ":关闭采购入库单" + JSON.toJSONString(httpResult));
        return httpResult;
    }

    /**
     * 销售退回回传
     *
     * @param uploadBase
     * @return
     */
    @Override
    public HttpResult getSaleBack(UploadBase uploadBase) {
        log.info("获取九州通入库单查询条件(销售退回回传)" + JSON.toJSONString(uploadBase));
        HttpResult<GET_InStock> httpResult = jztApi.HttpRequest(uploadBase);
        log.info("获取九州通入库单返回的数据(销售退回回传)" + JSON.toJSONString(httpResult));
        return httpResult;
    }
}
